package net.pimpas.web.jsf.components.accordionpanel;

import javax.faces.context.FacesContext;

import net.pimpas.web.jsf.components.UIComponentPimpasBase;
import net.pimpas.web.jsf.util.ComponentInformation;

public class UIAccordionPanel extends UIComponentPimpasBase {
	
	public static final String COMPONENT_TYPE			= ComponentInformation.COMPONENT_PREFIX_TYPE+".accordionpanel";
	public static final String COMPONENT_FAMILY			= ComponentInformation.COMPONENT_PREFIX_FAMILY+".accordionpanel";
	public static final String COMPONENT_RENDER_TYPE	= ComponentInformation.COMPONENT_PREFIX_RENDER+".accordionpanel";
	
	public static final String DEFAULT_COMPONENT_PATH	= "accordionpanel/";
	public static final String DEFAULT_ICON 			= "default_icon.png";
	public static final String DEFAULT_TOP_IMAGE		= "accordPanelTop.gif";
	public static final String DEFAULT_BOTTOM_IMAGE		= "accordPanelBottom.gif";
	public static final String DEFAULT_TITLE_IMAGE		= "accordPanelTitle.gif";
	public static final String DEFAULT_DROPDOWN_DOWN	= "up_minus.png";
	public static final String DEFAULT_DROPDOWN_UP		= "up_plus.png";
	public static final String DEFAULT_CSS				= "accordPanel.css";
	public static final String DEFAULT_JS				= "accordPanel.js";
	
	public static final String COLAPSED_STATE			= "COLAPSED";
	public static final String EXPANDED_STATE			= "EXPANDED";
	public static final String CONTENT_ID				= "_content";
	public static final String COMPONENT_CONTENT		= "component_content";
	
	private String title;
	private String icon;
	private String state;
	private String componentPath;
	
	@Override
	public Object saveState(FacesContext context) {
		Object[] ob = new Object[5];
		ob[0] = super.saveState(context);
		ob[1] = this.getTitle();
		ob[2] = this.getIcon();
		ob[3] = this.getState();
		ob[4] = this.getComponentPath();
		
		return ob;
	}
	
	@Override
	public void restoreState(FacesContext context, Object state) {
		Object[] ob = (Object[]) state;
		super.restoreState(context, ob[0]);
		this.setTitle((String) ob[1]);
		this.setIcon((String) ob[2]);
		this.setState((String) ob[3]);
		this.setComponentPath((String) ob[4]);
	}

	@Override
	public String getRendererType() {
		return COMPONENT_RENDER_TYPE;
	}

	@Override
	public String getFamily() {
		return COMPONENT_FAMILY;
	}
	
	@Override
	public boolean getRendersChildren() {
		return true;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getComponentPath() {
		return componentPath;
	}

	public void setComponentPath(String componentPath) {
		this.componentPath = componentPath;
	}
}